# Magnetic Inverse Dataset (50 ± 10 μm standoff, 256x256 resolution)

## Overview

This repository contains a dataset similar to those used in **"Machine Learning for Improved Current Density Reconstruction from 2D Vector Magnetic Images"**. 

- This dataset contains **157,696 simulated magnetic field/current density/standoff distance sets**, created to teach neural networks to solve the magnetic inverse problem. 
- The data is divided into **154 sets of files** (B, J, and standoff distance), with **1024 different configurations per file**. 
- Configurations alternate between straight and curved wires every 8 indices.  
- This dataset contains data with a **256x256 resolution**, and standoff distances sampled from a normal distribution with **μ=50 μm, σ=10 μm**. 
- Trained models, model training scripts (for MAGIC-UNet architecture), inference and data analysis code, experimental data and validation data used in publication can be found at https://doi.org/10.7910/DVN/SD6PVP 
    - Note that while this datasets was generated from the same data distribution as the data used to train the model, none of the included configurations were used in our training set. Thefore, all data in these collections can also serve as validation data to our trained networks.


## Contents

1. [Citation](#citation)
2. [Getting Started](#getting-started)
3. [Data Description](#data-description)
4. [Other Datasets](#training-datasets)

---

## Citation

If you use this dataset or associated scripts in your research, please cite the following paper and/or dataset:

```
@article{reed_machine_2024,
	title = {Machine {Learning} for {Improved} {Current} {Density} {Reconstruction} from {2D} {Vector} {Magnetic} {Images}},
	url = {http://arxiv.org/abs/2407.14553},
	publisher = {arXiv},
	author = {Reed, Niko R. and Bhutto, Danyal and Turner, Matthew J. and Daly, Declan M. and Oliver, Sean M. and Tang, Jiashen and Olsson, Kevin S. and Langellier, Nicholas and Ku, Mark J. H. and Rosen, Matthew S. and Walsworth, Ronald L.},
	month = jul,
	year = {2024},
}

@data{DVN/QPCS0I_2025,
author = {Reed, Niko and Turner, Matthew and Daly, Declan and Tang, Jiashen and Walsworth, Ronald},
publisher = {Harvard Dataverse},
title = {{Training data for reconstructing current density from magnetic field (50 ± 10 μm standoff, 64x64 resolution)}},
year = {2025},
doi = {10.7910/DVN/QPCS0I},
url = {https://doi.org/10.7910/DVN/QPCS0I}
}

```

---

## Data Description

All data has the following structure:

`[configuration index, spatial x, spatial y, component]`

Components are ordered, x, y, z.


### Parameters used to generate data:

| Parameter                    | Class I                                              | Class II                                             |
|------------------------------|-----------------------------------------------------|-----------------------------------------------------|
| Class of wire               | Curves formed by interpolating 2-21 randomly         | Thin right angle segments, thin arbitrary angle     |
|                              | generated points (with cropping)                    | segments, thick straight wires                     |
| Number of independent wires  | 1                                                   | 1, 2, or 3                                          |
| Field of view                | 2 mm                                                | 2 mm                                                |
| Standoff distance            | 50 ± 10 µm         | 50 ± 10 µm        |
| Thickness of current layer   | 14 µm                                               | 14 µm                                               |
| Width of wires (% of dataset)| 16-160 µm (50%), 160-320 µm (50%)                   | 9-30 µm (67%), 97-156 µm (33%)                     |
| Approximate Current Range    | 15.5 - 311 mA                                       | 1.95 - 170 mA                                       |

---

## Other Datasets

The following datasets are available for training:

- **50 micron and 64x64 resolution**: [https://doi.org/10.7910/DVN/QPCS0I](https://doi.org/10.7910/DVN/QPCS0I)
- **50 micron and 256x256 resolution**: [https://doi.org/10.7910/DVN/OPEX5N](https://doi.org/10.7910/DVN/OPEX5N)
- **500 micron and 64x64 resolution**: [https://doi.org/10.7910/DVN/SJDS2O](https://doi.org/10.7910/DVN/SJDS2O)

In addition, the following other types of data are available as part of the replication data for **"Machine Learning for Improved Current Density Reconstruction from 2D Vector Magnetic Images"** (DOI: [10.7910/DVN/SD6PVP](https://doi.org/10.7910/DVN/SD6PVP))

1. **Simulated In-Distribution Validation Data**: Validation data generated under conditions similar to the training data distribution; files include the configurations feautred in the paper figures. Note some validation files have data sorted by type (i.e first half of indices are type 1, second half are type 2)

2. **Simulated Out-of-Distribution Validation Data**: Validation data designed to test the model's performance under conditions outside the training data distribution.

3. **Experimental Data**: Data measured from a known current density distribution using nitrogen vacancy center magnetometry. For more details about the experimental setup, please refer to the supplemental information in the associated paper. Experimental data was taken at a variety of standoff distances, which can be estimated from the properties of the measured magnetic field.

   - Experimental data is available in the following resolutions:
     - **64x64 resolution**
     - **230x230 resolution**


---